package com.mjf.partition

import org.apache.flink.streaming.api.scala._

object BroadcastDemo {
  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment
    env.setParallelism(1)

    // 默认是轮询分区
    val source: DataStream[String] = env.fromElements(
      "1", "2", "3", "4", "5",
      "6", "7", "8", "9", "10",
      "11", "12", "13", "14", "15",
      "16", "17", "18", "19", "20"
    )
    source.print("source")

    // 广播
    val broadcast: DataStream[String] = source.broadcast
    broadcast.print("broadcast").setParallelism(3)

    env.execute(RescaleDemo.getClass.getName)

  }
}
